// 1002.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <vector>
using namespace std;

#define MAX_COUNT 10000
int debug_total_compare = 0;

struct Elephant
{
	int weight;
	int iq;
	int pos;
	bool visited;
	int arrive_list[ MAX_COUNT ];
	int arrive_count;

	inline bool operator< ( const Elephant& e )
	{
		return ( this->weight < e.weight ) && ( this->iq > e.iq );
	}
};

Elephant Elements[ MAX_COUNT ];
int element_count;
int L[ MAX_COUNT ];
int toposort_count;

void visit( int n )
{
	Elephant& e = Elements[n];
	e.visited = true;
	for( int i = 0; i < e.arrive_count; i++ )
	{
		int k = e.arrive_list[i];
		if( Elements[k].visited ) continue;
		visit( k );
	}
	L[ --toposort_count ] = n;
}

int main( int agrc, char* argv[] )
{

	element_count = 0;
	while( 1 )
	{
		Elephant& e = Elements[ element_count ];
		if( !( cin >> e.weight >> e.iq ) )
		{
			break;
		}
		e.pos = element_count + 1;
		e.visited = false;
		e.arrive_count = 0;

		for( int i = 0; i < element_count; i++ )
		{
			Elephant& d = Elements[i];
			if( e < d )
			{
				e.arrive_list[ e.arrive_count++ ] = i;
			}
			if( d < e )
			{
				d.arrive_list[ d.arrive_count++ ] = element_count;
			}
		}

		element_count++;
	}

	toposort_count = element_count;
	for( int i = 0; i < element_count; i++ )
	{
		if( Elements[i].visited ) { continue; }
		visit( i );
	}

	int length_to[ MAX_COUNT ] = {0};
	int prev[ MAX_COUNT ] = {0};

	for( int i = 0; i < element_count; i++ )
	{
		int p = L[i];
		Elephant& pe = Elements[p];
		for( int j = 0; j < pe.arrive_count; j++ )
		{
			int q = pe.arrive_list[j];
			if( length_to[q] < length_to[p] + 1 )
			{
				length_to[q] = length_to[p] + 1;
				prev[q] = p + 1;
			}
		}
	}

	int max_length = 0;
	int p = 0;
	for( int i = 0; i < element_count; i++ )
	{
		if( max_length <= length_to[i] )
		{
			max_length = length_to[i];
			p = i + 1;
		}
	}

	int rlist[ MAX_COUNT ] = {0};
	int* pr = rlist;
	while( p != 0 )
	{
		*(pr++) = p - 1;
		p = prev[ p - 1 ];
	}

	cout << max_length + 1 << endl;
	while( pr != rlist )
	{
		cout << Elements[ *(--pr) ].pos << endl;
	}
	return 0;
}
